# 模拟分布式计算 :(

from multiprocessing.managers import BaseManager

class QueueManager(BaseManager):
    pass


def worker():
    QueueManager.register('get_task_queue')
    QueueManager.register('get_result_queue')

    manager = QueueManager(address=('127.0.0.1', 9527), authkey=b'123')

    manager.connect()
    tasks = manager.get_task_queue()
    results = manager.get_result_queue()

    print('任务开始处理')

    for i in range(10):
        t = tasks.get()
        nt = 'taks is = {0}'.format(t)
        results.put(nt)

    print('任务处理完毕^v^')


if __name__ == '__main__':
    worker()